<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>fiopen</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="fink.html" title="fink" />
    <link rel="next" href="flanger.html" title="flanger" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">fiopen</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="fink.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="flanger.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="fiopen"></a>
      <div class="titlepage"></div>
      <a id="IndexFiopen" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">fiopen</span>
        </h2>
        <p>fiopen — 
      Opens a file in a specific mode.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp103385424"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>fiopen</em></span> can be used to open a file in one of the specified modes.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp103386960"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ihandle <span class="command"><strong>fiopen</strong></span> ifilename, imode</pre>
      </div>
      <div class="refsect1">
        <a id="idp103389072"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ihandle</em></span> -- a number which specifies this file.
    </p>
        <p>
      <span class="emphasis"><em>ifilename</em></span> -- the output file's name (in double-quotes).
    </p>
        <p>
      <span class="emphasis"><em>imode</em></span> -- choose the mode of opening the file. <span class="emphasis"><em>imode</em></span> can be a value chosen among the following:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p>0 - open a text file for writing</p>
            </li>
            <li class="listitem">
              <p>1 - open a text file for reading</p>
            </li>
            <li class="listitem">
              <p>2 - open a binary file for writing</p>
            </li>
            <li class="listitem">
              <p>3 - open a binary file for reading</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp103396592"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>fiopen</em></span> opens a file to be used by the <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a> family of opcodes. It is safer to use it in the header section, external to any instruments. It returns a number, <span class="emphasis"><em>ihandle</em></span>, which unequivocally refers to the opened file.
    </p>
        <p>
      If <span class="emphasis"><em>fiopen</em></span> is called on an already open file, it just returns the same handle again, and does not close the file.
    </p>
        <p>
      Notice that <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a> and <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a> can use either a string containing a file pathname, or a handle-number generated by <span class="emphasis"><em>fiopen</em></span>. Whereas, with <a class="link" href="fouti.html" title="fouti"><em class="citetitle">fouti</em></a> and <a class="link" href="foutir.html" title="foutir"><em class="citetitle">foutir</em></a>, the target file can be only specified by means of a handle-number.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp103405616"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the fiopen opcode. It uses the file <a class="ulink" href="examples/fiopen.csd" target="_top"><em class="citetitle">fiopen.csd</em></a>.
            </p>
        <div class="example">
          <a id="idp103407472"></a>
          <p class="title">
            <strong>Example 259. Example of the fiopen opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o fiopen.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2 
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 

gihand <span class="opc">fiopen</span> "test1.txt", 0 

<span class="oblock">instr</span> 1

ires  <span class="opc">random</span>  0, 100
      <span class="opc">fouti</span> gihand, 0, 1, ires 
      <span class="opc">ficlose</span> gihand 

<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="stamnt">i</span> 1 0 1 

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp103411760"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="ficlose.html" title="ficlose"><em class="citetitle">ficlose</em></a>
      <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a>, 
      <a class="link" href="fouti.html" title="fouti"><em class="citetitle">fouti</em></a>, 
      <a class="link" href="foutir.html" title="foutir"><em class="citetitle">foutir</em></a>, 
      <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp103417616"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
          <tr>
            <td>1999</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.56</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="fink.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="flanger.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">fink </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> flanger</td>
        </tr>
      </table>
    </div>
  </body>
</html>
